﻿using System;
using System.Collections.Generic;
using System.Text;
 


namespace Model
{
    public class Entity 
    {
        private EntityKey key_;
        private List<ColumnDefine> col_;

        public string TalbeName { get; set; }

        public EntityKey PrimaryKey
        { 
            get { return key_; }
            set { key_ = value; }
        }
        public List<ColumnDefine> Cols
        {
            get { return col_; }
            set { col_ = value; }
        }
        public void SetPrimaryKey(object key)
        {
            key_.SetPrimaryKey(key);
        }
        public ColumnDefine Find(object value)
        {
            if (key_ == null||value==null||Convert.ToString(value).Trim()==string.Empty)
                return null;
           ColumnDefine col= key_.Find(value);
           if (col != null)
               return col;

           foreach (ColumnDefine c in col_)
           {
               if (c.Value.Equals(value))
                   return c;
           }
           return null;
        }
    }
}
